All files / web/src/app/observe/[token] SessionEndedClient.tsx

0% Statements 0/203
0% Branches 0/1
0% Functions 0/1
0% Lines 0/203

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204                                                                                                                                                                                                                                                                                                                                                                                                                       
'use client'

import Link from 'next/link'
import { css } from '../../../../styled-system/css'
import { SubscribeButton } from '@/components/notifications/SubscribeButton'
import { SessionSongPlayer } from '@/components/practice/SessionSongPlayer'

interface SessionEndedClientProps {
  studentName: string
  studentEmoji: string
  sessionCompleted: boolean
  playerId: string
  sessionPlanId: string
  shareToken: string
  /** URL to the session report (only shown if user has access) */
  sessionReportUrl?: string
  /** Set if the viewer is authenticated */
  userId?: string
}

export function SessionEndedClient({
  studentName,
  studentEmoji,
  sessionCompleted,
  playerId,
  sessionPlanId,
  shareToken,
  sessionReportUrl,
  userId,
}: SessionEndedClientProps) {
  return (
    <div
      data-component="session-ended-page"
      className={css({
        minHeight: '100vh',
        display: 'flex',
        flexDirection: 'column',
        bg: 'bg.canvas',
      })}
    >
      {/* Banner with link to session report (only shown if user has access) */}
      {sessionReportUrl && sessionCompleted && (
        <div
          data-element="session-report-banner"
          className={css({
            bg: 'green.500',
            color: 'white',
            py: 3,
            px: 4,
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'center',
            gap: 3,
            flexWrap: 'wrap',
            textAlign: 'center',
          })}
        >
          <span className={css({ fontWeight: 'medium' })}>
            You have access to view the full session report.
          </span>
          <Link
            href={sessionReportUrl}
            className={css({
              display: 'inline-flex',
              alignItems: 'center',
              gap: 1,
              bg: 'white',
              color: 'green.700',
              px: 4,
              py: 1.5,
              borderRadius: 'md',
              fontWeight: 'semibold',
              fontSize: 'sm',
              transition: 'all 0.2s',
              _hover: {
                bg: 'green.50',
              },
            })}
          >
            View Session Report
            <span aria-hidden="true">→</span>
          </Link>
        </div>
      )}

      <div
        className={css({
          flex: 1,
          display: 'flex',
          flexDirection: 'column',
          alignItems: 'center',
          justifyContent: 'center',
          p: 6,
          textAlign: 'center',
        })}
      >
        <div
          className={css({
            fontSize: '6xl',
            mb: 4,
          })}
        >
          {sessionCompleted ? '🎉' : '⏳'}
        </div>

        <h1
          className={css({
            fontSize: '2xl',
            fontWeight: 'bold',
            color: 'text.primary',
            mb: 2,
          })}
        >
          {sessionCompleted ? 'Practice Session Complete!' : 'Session Not Started'}
        </h1>

        <p
          className={css({
            fontSize: 'lg',
            color: 'text.secondary',
            mb: 6,
            maxWidth: '400px',
          })}
        >
          {sessionCompleted
            ? `${studentEmoji} ${studentName} has finished their practice session.`
            : `${studentEmoji} ${studentName}'s practice session hasn't started yet.`}
        </p>

        {/* Session song player — shown when session completed */}
        {sessionCompleted && (
          <div data-element="session-song" className={css({ w: '100%', maxW: '480px', mb: 4 })}>
            <SessionSongPlayer playerId={playerId} planId={sessionPlanId} />
          </div>
        )}

        {!sessionReportUrl && sessionCompleted && (
          <p
            className={css({
              fontSize: 'sm',
              color: 'text.muted',
              mb: 6,
            })}
          >
            If you have an account with access to this student, you can sign in to view the session
            report.
          </p>
        )}

        {!sessionCompleted && (
          <p
            className={css({
              fontSize: 'sm',
              color: 'text.muted',
              mb: 6,
            })}
          >
            Check back once the session has started.
          </p>
        )}

        {/* Notification subscribe CTA */}
        {sessionCompleted && (
          <div
            data-element="subscribe-cta"
            className={css({
              marginBottom: 6,
            })}
          >
            <SubscribeButton
              playerId={playerId}
              playerName={studentName}
              userId={userId}
              shareToken={shareToken}
              variant="prominent"
            />
          </div>
        )}

        <Link
          href="/"
          className={css({
            display: 'inline-flex',
            alignItems: 'center',
            gap: 2,
            px: 6,
            py: 3,
            bg: 'brand.500',
            color: 'white',
            borderRadius: 'lg',
            fontWeight: 'semibold',
            transition: 'all 0.2s',
            _hover: {
              bg: 'brand.600',
            },
          })}
        >
          Go to Home
        </Link>
      </div>
    </div>
  )
}